package com.dnjn.happiness.biz.api.factory;

import com.dnjn.happiness.biz.api.RemoteEmotionTypeService;
import com.dnjn.happiness.common.core.domain.R;
import com.dnjn.happiness.common.core.model.EmotionTypeVO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;

public class RemoteEmotionTypeFallbackFactory implements FallbackFactory<RemoteEmotionTypeService> {

    private static final Logger log = LoggerFactory.getLogger(RemoteEmotionTypeFallbackFactory.class);
    @Override
    public RemoteEmotionTypeService create(Throwable throwable) {
        log.error("调用情绪类型服务失败：" + throwable.getMessage());
        return new RemoteEmotionTypeService() {
            @Override
            public R<EmotionTypeVO> getByCode(String code, String source) {
                return R.fail("查询情绪类型失败：{}" + throwable.getMessage());
            }
        };
    }
}
